package com.demo.support.task;

import java.util.HashMap;
import java.util.Map;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.jweb.annotaion.JTask;
import com.jweb.core.JWebFilter;
import com.jweb.log.Logger;
import com.jweb.util.FormatUtil;
import com.jweb.util.HttpClientUtil;
import com.jweb.util.MailUtil;

@JTask(cron = "0 0/10 * * * ?", jobName = "发送邮件", triggerName = "JtaskJob")
public class SendEmailJob implements Job {

	private Logger log = Logger.getLogger(getClass());

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		log.info("任务执行:[{}] ", this.getClass().getAnnotation(JTask.class).toString());
		try {
			String email = JWebFilter.getConstants().get("email.temp.url");
			String emailValue = HttpClientUtil.sendGet(email, "");
			Map<String, String> params = new HashMap<String, String>();
			params.put("name", "袁启勇先生");
			params.put("nowTime", FormatUtil.getNowTime());
			emailValue = FormatUtil.formatParams(emailValue, params);
			MailUtil mail = new MailUtil("yuanqy@aliyun.com", "yqy563930552", "aliyun");// 发送方
			mail.sendMail(new String[] { "563930552@qq.com" }, "支付之家邮箱验证", emailValue, "明天网络科技");

			// JWebFilter.getJdbctemplate().update("INSERT INTO test.test (name,pwd,create_time) VALUES (?,?,NOW())",
			// new Object[] { "AAb", "bbc" });

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
